<?php
/**
 * Created by PhpStorm.
 * User: MIS
 * Date: 2018/10/25
 * Time: 11:35
 */
namespace Admin\Controller;
use Think\Controller;
class EditSelectController extends Controller
{
    public function index()
    {
     $id=I("id");
     $tid=session("tid");
//     var_dump($id);
//        var_dump($tid);
//     exit();
        if($id){
            $select = M('select');
            $this->select_litem=$select->where('`id`='.$id)->find();
//            var_dump($this->select_litem);
//            var_dump($this->select_litem["id"]);
//            exit();
            $this->assign('select_litem',$this->select_litem);
            $this->assign('select_text',"updata");
        }else{
            $this->assign('select_text',"add");
        }
        $this->display();
    }
  public function  add(){
//        var_dump("1111111111");
//        exit();
    $select = M('select');
      $data=array(
          "content"=>I("content"),
          "select_a"=>I("select_a"),
          "select_b"=>I("select_b"),
          "select_c"=>I("select_c"),
          "select_d"=>I("select_d"),
          "success"=>I("success"),
          "tid"=>session("tid")

      );
        if($select->add($data)){
            $this->success('选择题添加成功',U('/Admin/Select/index',array('id'=>$_SESSION["id"])));
        }else{
            $this->error('选择题添加失败');
        }

}

    public  function  updata(){
        $select=M('select');
        $data=array(
            "content"=>I("content"),
            "select_a"=>I('select_a'),
            "select_b"=>I('select_b'),
            "select_c"=>I('select_c'),
            "select_d"=>I('select_d'),
            "success"=>I('success'),

        );
        $id=I('id');
        $flag=$select->where('`id`='.$id)->setField($data);

        if($flag){
            $this->success('选择题修改成功',U('/Admin/Select/index',array('id'=>$_SESSION["id"])));
        }else{
            $this->error('选择题修改失败');
        }
    }

    public function uptime($id){
        $text = M('test');
        $data=array(
            "uptime"=>time(),
        );
        $text->where('`id`='.$id)->setField($data);
    }




}